<?php
class Utilisateur {
	
	private $id;
	private $pseudo;
	private $password;
	private $active;
	private $role;
	
	public function Utilisateur() {
		$this->id;
		$this->pseudo;
		$this->password;
		$this->role;
	}
	
	public function getId() {
		return $this->id;
	}
	
	public function getPseudo() {
		return $this->pseudo;
	}
	
	public function getPassword() {
		return $this->password;
	}
	
	public function getActive() {
		return $this->active;
	}
	
	public function getRole() {
		return $this->role;
	}
	
	public function setId($id) {
		$this->id = $id;
	}
	
	public function setPseudo($pseudo) {
		$this->pseudo = $pseudo;
	}
	
	public function setPassword($password) {
		$this->password = $password;
	}
	
	public function setActive($active){
		$this->active = $active;
	}
	
	public function setRole($role) {
		$this->role = $role;
	}
	
	public function getAll() {
		$connect = new Connect ();
		$connect = $connect->findAll ( 'utilisateurs' );
		return $connect;
	}
	
	public function getOne($id) {
		$connect = new Connect ();
		$connect = $connect->findById ( 'utilisateurs', $id );
		return $connect;
	}
	
	public function save(Utilisateur $user) {
		$connect = new Connect ();
		$connect = $connect->insert ( 'utilisateurs', array ('pseudo' => $user->getPseudo (), 'password' => $user->getPassword (),'active' => $user->getActive(), 'role_id' => $user->getRole () ) );
		return $connect;
	}
	
	public function update($id, Utilisateur $user) {
		$connect = new Connect ();
		$connect = $connect->update ( 'utilisateurs', $id, array ('pseudo' => $user->getPseudo (), 'password' => $user->getPassword (),'active' => $user->getActive(), 'role_id' => $user->getRole () ) );
		return $connect;
	}
	
	public function delete($id) {
		$connect = new Connect ();
		$connect = $connect->delete ( 'utilisateurs', $id );
		return $connect;
	}
	
	public function getContact($id) {
		$connect = new Connect();
		$connect = $connect->find('users_contacts',array('utilisateur_id' => $id));
		return $connect;
	}
	
}